package com.android.lovingpet.bean;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.android.lovingpet.R;
import com.bumptech.glide.Glide;

import java.util.List;


/**
 * Created by ikata on 2018/2/27.
 */

public class GuideAdapter extends PagerAdapter {

    private List<Integer> images;
    private Context mContext;

    public GuideAdapter(List<Integer> images, Context mContext) {
        this.images = images;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return images.size();
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        ImageView imageView = new ImageView(mContext);
        imageView.setScaleType(ImageView.ScaleType.CENTER);
        Glide.with(mContext).load(images.get(position)).into(imageView);
        container.addView(imageView);
        return imageView;
    }
}
